// $Id: AccessSettingsEditor.cs 64 2008-05-06 18:29:47Z nvivo $

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.IO;
using System.Text;
using System.Windows.Forms;

namespace DBLGen.Plugins.Import
{
    public partial class AccessSettingsEditor : UI.PluginSettingsEditor
    {
        public AccessSettingsEditor()
        {
            InitializeComponent();
        }

        public new AccessSettings Settings
        {
            get
            {
                return (AccessSettings) base.Settings;
            }
            set
            {
                base.Settings = value;
            }
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                if (Directory.Exists(txtDatabase.Text))
                    dlg.InitialDirectory = Path.GetDirectoryName(txtDatabase.Text);

                dlg.Filter = "Microsoft Access Databases (*.mdb)|*.mdb|All Files (*.*)|*.*";
                
                if (dlg.ShowDialog() == DialogResult.OK)
                    txtDatabase.Text = dlg.FileName;
            }
        }

        private void AccessSettingsEditor_LoadingSettings(object sender, EventArgs e)
        {
            txtDatabase.Text = Settings.FilePath;
        }

        private void AccessSettingsEditor_SavingSettings(object sender, EventArgs e)
        {
            Settings.FilePath = txtDatabase.Text;
        }
    }
}
